home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / applications / wp / pastex-ged.lha / PasTeX-GoldED / Start_plainTeX.ged < prev    next >
Encoding:
Text File  |  1994-05-01  |  3.4 KB  |  129 lines

  1. /*RX
  2.  * AREXX        Name:Start_TeX.ged      Version:2.00    Date:28-Feb-94
  3.  *
  4.  This AREXX script saves and compiles the current GoldED window. The only
  5. (optional) argument is the format to be used. A '?' formatname will
  6. interactively ask for the format to use.
  7.  *
  8.  A command is send to the TeX server to compile the file. Hence a
  9. return value of 0 does not mean that the file compiled well, but only
  10. that the command was sent to the server and replied to.
  11.  *
  12. AUTHOR:
  13.  *   René Laederach, February 94
  14.  *
  15. BUGS:
  16.  virtex doesn't like filenames with blanks (and ARexx parses them
  17. hardly too), so avoid them in file, directory *and* device names.
  18.  *
  19.  Does not like names relative to the local root, like ":foo/bar"
  20.  Although I can't think GoldED will ever do that.
  21.  *
  22. FILES:
  23.  ENV:TEXFORMAT: default format used
  24.  REXX:namestruc
  25.  *
  26. Done by:
  27.  
  28. R.Laederach
  29. Kappelisackerstr. 46
  30. 3063 Ittigen
  31. Switzerland
  32. Phone:+41/(0)31/912 19 08
  33.  
  34. This stuff ist PostcardWare, so send me a postcard or something useful (read
  35. the doc!).
  36.  */
  37.  
  38. /* $VER: 0.9, ©1993 Dietmar Eilert. Empty GoldED macro */
  39.  
  40. OPTIONS RESULTS                             /* enable return codes     */
  41.  
  42. if (LEFT(ADDRESS(), 6) ~= "GOLDED") then    /* not started by GoldEd ? */
  43.     address 'GOLDED.1'
  44.  
  45. 'LOCK CURRENT'                              /* lock GUI, gain access   */
  46. OPTIONS FAILAT 6                            /* ignore warnings         */
  47. SIGNAL ON SYNTAX                            /* ensure clean exit       */
  48.  
  49. portname = 'Start_TeX'
  50. script   = 'TeX-server.rexx'    /* no path required, message only       */
  51.  
  52. IF "" = GETCLIP("TEXQUERY") THEN askformat = 0
  53. ELSE askformat = 1              /* ask interactively for format name    */
  54.  
  55. format = "&plain"
  56.  
  57. 'QUERY DOC'       /* full filename */
  58. filename=RESULT
  59.  
  60.  
  61. IF "" == filename | UPPER(RIGHT(filename,3)) ~= "TEX" THEN DO
  62.         'REQUEST TITLE="Beware!" BODY="Sorry, filename must have an extension and end in .tex."'
  63.         UNLOCK
  64.         EXIT 5
  65.         END
  66.  
  67. 'QUERY MODIFY'
  68.  
  69. if (RESULT = 'TRUE') THEN DO
  70.     'SAVE ALL'
  71.     END
  72.  
  73. IF (SHOW('P', portname)) THEN DO
  74.         /* set the default format, modify it to suit your needs */
  75.         envformat = mygetenv("TEXFORMAT")
  76.         IF "" == format THEN DO
  77.             format = envformat
  78.             IF askformat | "" = envformat THEN DO
  79.                 IF "" = format THEN format = 'plain'
  80.  
  81.                 'REQUEST TITLE="Question!" BODY="Which format to use ?" STRING VAR NFORMAT'
  82.                 IF "RESULT" ~= nformat THEN format = nformat
  83.  
  84.                 END /* askformat */
  85.             END /* format */
  86.  
  87.         if format ~= envformat THEN CALL mysetenv("TEXFORMAT",format)
  88.  
  89.         'UNLOCK'
  90.         ADDRESS VALUE portname
  91.         'compile' format filename
  92.         EXIT 0 /* Do it here to avoid multiple "Waiting for command..." messages in TeX server window */
  93.         END
  94. ELSE DO
  95.         /* The TeX server must be started first */
  96.         'REQUEST TITLE="Warning!" BODY="The TeX server script is not running !"'
  97.         UNLOCK
  98.         EXIT 5
  99.         END
  100.  
  101. 'UNLOCK' /* VERY important: unlock GUI */
  102.  
  103. EXIT
  104.  
  105. SYNTAX:
  106.  
  107. SAY "Sorry, error line" SIGL ":" ERRORTEXT(RC) ":-("
  108. 'UNLOCK'
  109. EXIT
  110.  
  111. mygetenv: procedure     /* when will ARexx supply GetEnv/SetEnv ? */
  112.    PARSE ARG name
  113.  
  114.    IF open(TEMPFILE,"ENV:"||name,'r') THEN DO
  115.         gives = readln(TEMPFILE)
  116.         CALL close TEMPFILE
  117.         END
  118.    ELSE gives = ""
  119.  
  120.    RETURN gives
  121.  
  122. mysetenv: procedure
  123.    PARSE ARG name,content
  124.  
  125.    ADDRESS COMMAND "SetEnv" name content
  126.  
  127.    RETURN
  128.  
  129.